package com.vic.mesage_ack;

import com.rabbitmq.client.Channel;
import com.vic.utils.RabbitmqUtils;

import java.nio.charset.StandardCharsets;

/**
 * 发送者
 */
public class Producer {

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitmqUtils.getChannel();
        // 声明队列
        channel.queueDeclare(Consts.QUEUE_NAME, false, false, false , null);
        // 发送10条消息
        for (int i = 1; i <= 10; i++) {
            channel.basicPublish("", Consts.QUEUE_NAME, null, ("好消息" + i).getBytes(StandardCharsets.UTF_8));
        }
        System.out.println("发送消息完成");

    }

}
